<!DOCTYPE html>
<html>
	<head>
	    <meta charset="UTF-8">
	    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	    <meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
	    <title>邀请有礼</title>
	    <script type="text/javascript" src="../../js/mui.min.js"></script> 
	    <script type="text/javascript" src="../../js/common.js"></script>
	    <link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
	    <link rel="stylesheet" href="../../css/own.css" />
	    <script src="../../js/jquery-1.11.3.js"></script>
	    <style>
	    	#item1 p{
	    		font-size: 12px;;
	    		background-color: #FFFFFF;
	    		color:#666666;
	    		line-height: 20px;
	    		padding: 5px 10px;
	    		border-bottom: 1px solid #e6e6e6;
	    		margin-bottom: 5px;
	    	}
	    	#linkDiv {
	    		padding: 5px 10px;
	    		background-color: #FFFFFF;
	    		border-bottom: 1px solid #e6e6e6;
	    		border-top:1px solid #E6E6E6
	    	}
	    	#linkDiv label{
	    		font-size: 12px;
	    		line-height: 30px;
	    		color: #2B2B2B;
	    		vertical-align: middle;
	    	}
	    	#shareButton{
	    		background-color: #fcc900;
	    		color:#2b2b2b;
	    		font-size: 12px;
	    		border: none;
	    		display: block;
	    		float: right;
	    	}
	    	#shareDivContent{
	    		padding: 0px 10px;
	    		background-color: #f2f2f2;
	    		border-bottom: 1px solid #e6e6e6;
	    	}
	    	#guize{
	    		padding: 0px 10px;
	    		background-color: #FFFFFF;
	    	}
	    	#guize p:nth-child(1){
	    		border-bottom: 1px solid #e6e6e6;
	    		line-height: 40px;
	    		font-size: 14px;
	    		color:#2b2b2b;
	    		padding: 0px;
	    		height: 40px;
	    	}
	    	#guize p label:nth-child(2){
	    		color:#fcc900;
	    		display: block;
	    		float: right;
	    		padding-right: 20px;
	    		background-image: url(../../images/sharearrow.png);
	    		background-repeat: no-repeat;
    			background-position:  right center;
    			background-size: 15%;
	    	}
	    	#guize p:nth-last-child(1){
	    		color:#999999;
	    		font-size: 12px;
	    		line-height: 20px;
	    		padding-top: 0px;
	    	}
	    	#callService{
	    		width: 100%;
	    		text-align: center;
	    		height: 40px;
	    		line-height: 40px !important;
	    		background-color: #2B2B2B !important;
	    		color:#FFFFFF!important;	
	    		padding: 0px!important;
	    		position: fixed;
	    		bottom: -1px;
	    		margin: 0px!important;
	    	}
	    	#historyDetailsTable1 {
	    		padding-bottom: 20px;
	    		background-color: #FFFFFF;
	    	}
	    	#historyDetailsTable1 thead td{
	    		color:#2B2B2B;
	    		font-size: 12px;
	    		height: 30px;
	    		line-height: 30px;
	    		padding-left: 13px;
	    	}
	    	#historyDetailsTable1  thead tr{
	    		border-bottom: 1px solid #e6e6e6;
	    	}
	    	#historyDetailsTable1 tbody tr{
	    		padding: 13px 0px;
	    		border-bottom: 1px solid #e6e6e6;
	    		color:#666666;
	    		height: 30px;
	    		font-size: 12px;
	    		line-height: 30px;
	    	}
	    	#historyDetailsTable1 tbody tr td{
	    		padding-left: 13px;
	    		line-height: 30px;
	    	}
	    	#shareTitle{
	    		background-color: #1f1f1f;
	    		padding: 11px 0px;
	    	}
	    	#shareTitle p{
	    		padding: 0px;
	    		line-height: 14px;
	    		font-size: 12px;
	    	}
	    	#shareTitle p label{
	    		color:#FFFFFF;
	    		display: inline-block;
	    		width: 33%;
	    		text-align: center;
	    	}
	    	.fcc900{
	    		color: #fcc900 !important;
	    	}
	    	#shareDivContent p{
	    		padding: 0px;
		    	background-color: #f2f2f2;
		    	border: none;
		    	margin: 0px;
	    	}
	    	#shareDivContent p:nth-child(2){
	    		padding: 10px 0px;
	    	}
	    	#shareDivContent p:nth-child(3){
	    		margin-bottom: 20px;
	    	}
	    	#shareDivContent p label{
	    	display: inline-block;
	    	width: 33%;
	    	text-align: center;
	    	font-size: 12px;
	    	color:#666666;
	    	}
	    	#shareDivContent p label img{
	    		width: 60%;
	    	}
	    	#item2{
	    		width: 100%;
				overflow-x: scroll;
				overflow-y: hidden;
	    	}
		.mui-pull-bottom-tips {
				text-align: center;
				font-size: 15px;
				line-height: 40px;
				color: #777;
		}
		.mui-pull-loading { 
		    margin-right: 10px;
		    -webkit-transition: -webkit-transform .4s;
		    transition: transform .4s;
		    -webkit-transition-duration: 400ms;
		    transition-duration: 400ms;
		    vertical-align: middle;
		}
		#inviteUrl{
			display: inline-block;
			width: 50%;
			white-space: nowrap;
			text-overflow: ellipsis;
			overflow: hidden;
		}
	    </style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav own-topbg">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" id="back"><i>返回</i></a>
			<h1 class="mui-title">邀请有礼</h1>		
			<!--<a href="javascript:void(0)" class="top-tel" id="telBtn">客服热线</a>-->
		</header>	
		<div class="mui-content sc_listdeta" id="listDetails" style="padding-bottom: 0px;">
			<div  class="mui-slider-indicator mui-segmented-control">
				<a class="mui-control-item mui-active" href="#item1" id="detailButton">我的邀请码</a>
				<a class="mui-control-item" href="#item2" id="historyButton">邀请记录</a>
			</div>
			<div id="item1" class="mui-control-content mui-active">	
				<p>分享以下邀请链接，好友通过您的链接注册成功完成实名认证，并成功申请方案，您可获得免手续费的奖励，可累计。</p>
				<div id="linkDiv">
					<label>邀请链接：</label>
					<label id="inviteUrl"></label>
					<button id="shareButton">复制链接</button>
				</div>
				<div id="shareDivContent">
					<img src="../../images/fenxiang.png" width="100%" height="auto">
					<p><label class="shareWexin"><img src="../../images/weixinshare.png"></label><label class="shareWeibo"><img src="../../images/weiboshare.png"></label><label class="qq"><img src="../../images/qqshare.png"></label></p>
					<p><label class="shareWexin">微信朋友圈</label><label class="shareWeibo">新浪微博</label><label class="qq">QQ好友</label></p>
				</div>
				<div id="guize">
					<p><label>邀请好友，免交易手续费！</label><label id="test">活动规则</label></p>
					<p>多拉新朋友，即可多获减免奖励。比如小明叫了10个朋友来国际期货通金融操盘，8个进行了实名认证，其中6个人操盘交易均达到双边5手。那么小明就可以获得（累计）：2个1手交易费减免资格，4个2手交易费减免资格，总共1+1+2+2+2=2=10手双边免费交易资格。以此类推，多拉新用户多得减免金。</p>
				</div>
				<p id="callService">联系电话：400-180-1860</p>
			</div>
			<div id="item2" class="mui-control-content ">
				<div class="mui-scroll-wrapper">
					<div class="mui-scroll" id="mui-scroll">
						<div id="shareTitle">
							<p><label>注册人数</label><label>申请方案人数</label><label>已获奖励次数</label></p>
							<p><label class="fcc900" id="registNum">0</label><label class="fcc900" id="ftradeNum">0</label><label class="fcc900" id="awardSum">0</label></p>
						</div>
						<div style="height: auto;width: 100%;overflow-x: scroll;">
							<table id="historyDetailsTable1" width="550px" cellpadding="0" cellspacing="0" border="0">
								<thead>
									<tr>
										<td width="50px">手机号</td>
										<td width="80px">姓名</td>
										<td width="120px">注册时间</td>
										<td width="120px">交易时间</td>
										<td width="80px">交易手数</td>
									</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
		<input id="sharecontent" type="hidden" value=""></input>
		<input id="sharehref" class="sharehref" type="hidden"/>
		<input id="sharehrefTitle" class="sharehref" type="hidden" value="原来国际期货赚钱这么简单，双边第一手还免费！"/>
		<input id="sharehrefDes" class="sharehref" type="hidden" value="我在国际期货通金融操盘国际期货，门槛低、手续费用低，你也来试试吧"/>
		<div id="output" style="opacity: 0;"></div>
	</body>
	<script src="../../js/mui.pullToRefresh.js"></script>
	<script src="../../js/mui.pullToRefresh.material.js"></script>
	<script src="../../js/share.js"></script>
	<script src="../../js/immersed.js"></script>
	<script>
				mui.init();
				var item = document.getElementById('item2');
			    var scheight = document.documentElement.clientHeight;
				var infoheihgt = scheight - 44 -60;
				item.style.height = infoheihgt + 'px';
				(function($) {
					var deceleration = mui.os.ios?0.003:0.0009;
					$('.mui-scroll-wrapper').scroll({
						bounce: false,
						indicators: true, //是否显示滚动条
						deceleration:deceleration
					});		
				})(mui);
				mui.plusReady(function(){
					mui(document.querySelector('#item2 .mui-scroll')).pullToRefresh({
						up: { 
							callback: function() {
								var self = this;
								var ul = self.element.querySelector('#historyDetailsTable1');
								setTimeout(function(){
									ajaxQueryPageInfo(self);	
								},500)
							}
						}
					});
					document.getElementById("test").addEventListener("tap",function(){
//						mui.openWindow("../buy/buy.html");
						var nid="http://www.mzkqh.com/topic/old/client/index.html"
						mui.openWindow({url:"../news/active.html",id:"active",extras:{nid:nid}});
					})
					var dataALL=[];
					var pageIndex=0;
					var perPage=20;
					var totalPage=0;
					var curreentPage=0;
					var mobile=plus.storage.getItem(tzdr.constants.user_mobile,mobile);
					mui.app_request("/activity/getOldAndNewInvitedList",{pageIndex:pageIndex,perPage:perPage},function(data){
							if(data.success==true){
								var dataall=data.data.pageResults;
								totalPage=data.data.totalPage;
								currentPage=data.data.currentPage;
								var length=dataall.length;
								for(var i=0;i<length;i++){
									var mobile=dataall[i].mobile;
									var user_mobile=mobile.substring(0,3)+"****"+mobile.substring(7,11);
									var ctime=new Date(dataall[i].ctime*1000).format("yyyy-MM-dd hh:mm:ss");
									var endTime=new Date(dataall[i].endTime*1000).format("yyyy-MM-dd hh:mm:ss");
									var name=dataall[i].tname;
									name=name.substr(0,1);
									var str="";
									for(var j=0;j<=name.length;j++){
										str=str+" *";
									}
									$("#historyDetailsTable1").append("<tr>" +
					                    "<td>"+user_mobile+"</td><td>"+name+str+"</td><td>"+ctime+"</td><td>"+endTime+"</td><td>"+dataall[i].sumLever+"</td>"+
					            "</tr>")
								}
								pageIndex=pageIndex+1;
							}
					},function(){});
					mui.app_request("/activity/oldAndNewInvitedStatistics",{},function(data){
						if(data.success==true){
							$("#ftradeNum").text(data.data.ftradeNum);
							$("#registNum").text(data.data.registNum);
							$("#awardSum").text(data.data.awardSum);
						}
					},function(){
						
					})
					function  ajaxQueryPageInfo(obj){
						if(Number(currentPage) >= Number(totalPage)){
							obj.endPullUpToRefresh(true);
							return
						}
						mui.app_request("/activity/getOldAndNewInvitedList",{pageIndex:pageIndex,perPage:perPage},function(data){
							if(data.success==true){
									var dataall=data.data.pageResults;
									var length=dataall.length;
									currentPage=data.data.currentPage;
									for(var i=0;i<length;i++){
										var mobile=dataall[i].mobile;
										var user_mobile=mobile.substring(0,3)+"****"+mobile.substring(7,11);
										var ctime=new Date(dataall[i].ctime*1000).format("yyyy-MM-dd hh:mm:ss");
										var endTime=new Date(dataall[i].endTime*1000).format("yyyy-MM-dd hh:mm:ss");
										var name=dataall[i].tname;
										name=name.substr(0,1);
										var str="";
										for(var j=0;j<=name.length;j++){
											str=str+" *";
										}
										$("#historyDetailsTable1").append("<tr>" +
						                    "<td>"+user_mobile+"</td><td>"+name+str+"</td><td>"+ctime+"</td><td>"+endTime+"</td><td>"+dataall[i].sumLever+"</td>"+
						            "</tr>")
									}
									pageIndex=pageIndex+1;
									obj.endPullUpToRefresh();
								}
						},function(){})
					}
					var isRealName;
					if(plus.storage.getItem("inviteUrl")==null){
						mui.app_request("/wechat/threePartyCreateQrcode",{mobile:mobile},function(data){
							if(data.success==true){
								$("#inviteUrl").text(data.data.inviteUrl);
								document.getElementById("sharehref").value=data.data.inviteUrl
//								$("#sharehref1").value(data.data.inviteUrl);
								isRealName=data.data.isRealName;
								plus.storage.setItem("inviteUrl",data.data.inviteUrl);
								plus.storage.setItem("isRealName",isRealName)
							}
						},function(){
							
						});
					}else{
						$("#inviteUrl").text(plus.storage.getItem("inviteUrl"));
						document.getElementById("sharehref").value=plus.storage.getItem("inviteUrl");
						isRealName=plus.storage.getItem("isRealName")
					}

					document.getElementById("shareButton").addEventListener("tap",function(){
						if(isRealName==false){
							mui.toast("您还没有实名认证");
							return
						}
						var text=$("#inviteUrl").text();
						copytoClip(text);
					})
					function copytoClip(text){
						if(plus.os.name=="Android"){
							var Context=plus.android.importClass("android.content.Context");
							var main=plus.android.runtimeMainActivity();
							var clip=main.getSystemService(Context.CLIPBOARD_SERVICE);
							plus.android.invoke(clip,"setText",text);   
							mui.toast("复制成功！");
						}else{
							var UIPasteboard=plus.ios.importClass("UIPasteboard");
							var generalPasteboard=UIPasteboard.generalPasteboard();
							generalPasteboard.setValueforPasteboardType(text,"public.utf8-plain-text");
							var value=generalPasteboard.valueForPasteboardType("public.utf8-plain-text");
							mui.toast("复制成功！");
						}
					}
					$(".shareWexin").on("tap",function(){
							var shareBts=[];
							var ss=shares['weixin'];
//							ss&&ss.nativeClient&&shareBts.push({title:'QQ',s:ss});
							ss&&ss.nativeClient&&(shareBts.push({title:'微信朋友圈',s:ss,x:'WXSceneTimeline'}));
//							shareBts.push({title:'微信好友',s:ss,x:'WXSceneSession'});
							shareAction(shareBts[0],true);
							// 分析链接
					});
					$(".shareWeibo").on("tap",function(){
						shareSystem();
//						var shareBts=[];
//						var ss=shares['sinaweibo'];
//						ss&&shareBts.push({title:'新浪微博',s:ss});
//						shareAction(shareBts[0],true);
					})
					$(".qq").on("tap",function(){
						var shareBts=[];
						var	ss=shares['qq'];
						ss&&ss.nativeClient&&shareBts.push({title:'QQ',s:ss});
						shareAction(shareBts[0],true);
					})
					document.getElementById("callService").addEventListener("tap",function(){
						mui.callService();
					})
					/**
					 * 调用系统分享
					 * 调用
					 */
				function shareSystem() {
						if(plus.os.name!=="Android"){
							plus.nativeUI.alert("此平台暂不支持系统分享功能!");
							return;
						}
						var intent=new Intent(Intent.ACTION_SEND);
						var p = "";
//						if(pic&&pic.realUrl){
//							p = pic.realUrl;
//							if(p.substr(0,7)==="file://"){
//								p=p.substr(7);
//							}else if(p.sub(0)!=="/"){
//								p=plus.io.convertLocalFileSystemURL(p);
//							}
//						}
						var f = new File(p);
						var uri = Uri.fromFile(f);
						if(f.exists()&&f.isFile()){
							intent.setType("image/*");
							intent.putExtra(Intent.EXTRA_STREAM,uri);
						}else{
							intent.setType("text/plain");
						}
						intent.putExtra(Intent.EXTRA_SUBJECT,"HBuilder");
						intent.putExtra(Intent.EXTRA_TEXT,sharecontent.value);
						intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
						main.startActivity(Intent.createChooser(intent,"系统分享"));
					}
				})
	</script>
</html>
